package com.rqbl.controller;

import com.rqbl.entity.User;
import com.rqbl.service.CommentLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/commentLike")
public class CommentLikeController {

    @Autowired
    private CommentLikeService commentLikeService;

    @RequestMapping("/selectCommentLikeByUCId")
    @ResponseBody
    public String selectCommentLikeByUCId(Integer cid,HttpSession  session) {
        User user = (User)session.getAttribute("user");;
        return commentLikeService.selectCommentLikeByUCId(user.getUid(),cid) > 0 ? "true":"false";
    }

    @RequestMapping("/insertCommentLike")
    @ResponseBody
    public String insertCommentLike(Integer cid, HttpSession  session) {
        User user = (User)session.getAttribute("user");
        return commentLikeService.insertCommentLike(user.getUid(),cid) > 0 ? "true":"false";
    }

    @RequestMapping("/deleteCommentLike")
    @ResponseBody
    public String deleteCommentLike(Integer cid,HttpSession  session) {
        User user = (User)session.getAttribute("user");
        return commentLikeService.deleteCommentLike(user.getUid(),cid) > 0 ? "true":"false";
    }

}
